package com.wxxymakers.grademark.config;

import com.jagregory.shiro.freemarker.ShiroTags;
import freemarker.template.Configuration;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import javax.annotation.PostConstruct;

/**
 * @AUTHOR soft
 * @DATE 2018/10/27 1:21
 * @DESCRIBE
 */
@Data
@org.springframework.context.annotation.Configuration
public class TemplateConfig {
    @Value("${contextPath}")
    private String root;

    private final Configuration configuration;

    @Autowired
    public TemplateConfig(Configuration configuration) {
        this.configuration = configuration;
    }

    @PostConstruct
    public void setConfigure() throws Exception {
        configuration.setSharedVariable("webOwner", "lkl");
        configuration.setSharedVariable("root", root);
        configuration.setSharedVariable("shiro", new ShiroTags());
    }
}
